package luj.tool.jnproxyan.proxy.admin.http.render;

import java.util.List;

/**
 * @deprecated 有vue之后就不需要了
 */
@Deprecated
public class ValueDefaultRenderer {

  public ValueDefaultRenderer(Object value) {
    _value = value;
  }

  public String render() {
    if (_value instanceof Double) {
      return String.format("%.2f", _value);
    }
    if (_value instanceof List) {
      return renderList((List<?>) _value);
    }
    return String.valueOf(_value);
  }

  private String renderList(List<?> list) {
    if (list.size() == 2) {
      return "(" + list.get(0) + "," + list.get(1) + ")";
    }
    return list.toString();
  }

  private final Object _value;
}
